﻿using System;
using System.Collections.Generic;

using G.Model;
using G.Model.Enums;

namespace GameLibrary.Internal
{
    public class MovePointGenerator
    {
        public MoveStratagyEnum Moves
        {
            get;
            set;
        }

        public GameLocation Start
        {
            get;
            set;
        }

        public ICollection<GameLocation> Generate()
        {
            List<GameLocation> test = new List<GameLocation>();
            switch(Moves) 
            {
                case MoveStratagyEnum.NEIGHBORING:
                {
                    Add(test, -1, 0);
                    Add(test, 1, 0);
                    Add(test, 0, -1);
                    Add(test, 0, 1);
                    break;
                }
                case MoveStratagyEnum.LEFT:
                {
                    Add(test, -1, 0);
                    break;
                }
                case MoveStratagyEnum.RIGHT:
                {
                    Add(test, 1, 0);
                    break;
                }
                case MoveStratagyEnum.UP:
                {
                    Add(test, 0, -1);
                    break;
                }
                case MoveStratagyEnum.DOWN:
                {
                    Add(test, 0, 1);
                    break;
                }
                case MoveStratagyEnum.UP_LEFT_RIGHT:
                {
                    Add(test, 0, -1);
                    Add(test, -1, 0);
                    Add(test, 1, 0);
                    break;
                }
                case MoveStratagyEnum.DOWN_LEFT_RIGHT:
                {
                    Add(test, 0, 1);
                    Add(test, -1, 0);
                    Add(test, 1, 0);
                    break;
                }
            }
            return test;
        }

        private void Add(List<GameLocation> list, int dx, int dy)
        {
            int x = Start.X + dx;
            int y = Start.Y + dy;
            if (x >= 0 && x <= 9 && y >= 0 && y <= 9)
            {
                GameLocation loc = new GameLocation(x, y);
                list.Add(loc);
            }
        }
    }
}
